package com.binarysearch;

/**
 * Created with IntelliJ IDEA.
 * User: Vadim
 * Date: 18.05.14
 * Time: 15:19
 * To change this template use File | Settings | File Templates.
 */
public class BinarySearch {
    static int arr[] = {34,8,9,10,11,13,24,12,19,33,4,5,6};

    public static int search(int low, int high){
        if(low > high)
            return - 1;
        if(arr[low] > arr[high]){
            int mid = (low + high) / 2;
            if(arr[mid] > arr[high])
                return search(mid + 1, high);
            else
                return search(low, mid);
        }
        return low;
    }

    public static void main(String[] args) {
        int min = BinarySearch.search(0, arr.length-1);
        System.out.println("Min element in array is = " + arr[min]);

    }
}
